package com.zhang.sequencegenerate.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zhang.sequencegenerate.entity.SequenceRecord;

/**
 * @Description
 * @Author Mr.Zhang
 * @Date 2025/5/25 21:03
 * @Version 1.0
 */
public interface SequenceRecordService extends IService<SequenceRecord> {

    /**
     * 查询序列
     *
     * @param sequenceKey
     * @return
     */
    SequenceRecord querySequence(String sequenceKey);

    /**
     * 采用乐观锁更新数据库序列值
     *
     * @param newValue
     * @param oldValue
     * @param sequenceKey
     * @return
     */
    int nextValue(long newValue, Long oldValue, String sequenceKey);
}
